package com.cm.stock.manager.service;

import java.util.Date;
import java.util.List;

import com.cm.stock.manager.dao.OperationDAO;
import com.cm.stock.manager.dto.FactureDTO;
import com.cm.stock.manager.dto.OperationDTO;

public class OperationService {
	
	private OperationDAO operationDAO;
	
	public OperationDTO getOperationByCode(String code){
		return operationDAO.getByCode(code);
		
	}
	
	
	public OperationDTO saveOperation(String typeoperation, double montantoperation, Date dateoperation, FactureDTO facture){
		String code = operationDAO.getMaxId()+"";
		return operationDAO.save(new OperationDTO(code, typeoperation, montantoperation, dateoperation, facture));
	}
	
	public OperationDTO updateOperation(OperationDTO operation){
		return operationDAO.update(operation);
	}
	
	public void deleteOperation (Integer id) throws Exception{
		operationDAO.deleteOne(id);
	}
	
	public List<OperationDTO> getOperationByDate(Date date){
		return operationDAO.getByDate(date);
	}


	public void setOperationDAO(OperationDAO operationDAO) {
		this.operationDAO = operationDAO;
	}
	
	

}
